Skip to content

Make the php command 2 times faster to start - #426

Merged
mistraloz merged 1 commit into
thecodingmachine:v5from
mistraloz:perf/php-proxy
Nov 5, 2026
Merged

mistraloz merged 1 commit into
thecodingmachine:v5from
mistraloz:perf/php-proxy

Conversation

@mistraloz

Copy link
Copy Markdown
Collaborator

Summary

This PR makes the php command 2 times faster to start:

  • Bug
  • Feature
  • Breaking changes

/usr/bin/php is a proxy that regenerates the PHP configuration when a PHP_* variable changed (e.g.
docker exec -e PHP_INI_MEMORY_LIMIT=1G). To detect it, it called sudo and started PHP a first time on each call.
It now compares a fingerprint of the PHP_* variables in bash, and only uses sudo and PHP when they changed.

It also detects the removed variables: the configuration was kept unchanged when a PHP_* variable was removed.

Measures (PHP 8.4, amd64, average of 300 php -r '' in a started container):

Before After
php -r '' 44 ms 21.4 ms
Proxy overhead (real_php alone: 19 ms) ~25 ms ~2.5 ms

Every php command benefits: Composer scripts, bin/console, cron jobs, tests...

Test plan (required)

New test test_environmentChangedAfterStart (php-ini.sh). It fails on the current images
(expected [512M -1] but was [512M 512M]).

TAG_PREFIX=pr-perf- docker buildx bake --load php8X-slim-<variant> php8X-<variant>
TAG_PREFIX=pr-perf- PHP_VERSION=8.X BRANCH=v5 VARIANT=<variant> ./tests-suite/bash_unit -f tap ./tests-suite/*.sh
PHP cli apache fpm
8.2 47/47 56/56 67/67
8.3 47/47 56/56 67/67
8.4 47/47 56/56 67/67
8.5 47/47 56/56 67/67

variant-node.sh was not run: the NodeJS images are not modified.

Checklist

  • I followed the guidelines in CONTRIBUTING guide
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code

@mistraloz
mistraloz merged commit 9d26108 into thecodingmachine:v5 Nov 5, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant